package com.briup.demo.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.briup.demo.bean.CmsComment;
import com.briup.demo.mapper.CmsCommentMapper;


@Service
public class CmsCommentService {

	@Autowired
	private CmsCommentMapper commentMapper;
	
	public int deleteById(String id) {
		return commentMapper.deleteByPrimaryKey(id);
		
	}
	
	public boolean artStatus(int status) {
		if(status==1) {
			return true;
		}else {
			return false;
		}
	}
	
	public List<CmsComment> getAllComment(){
		//List<CmsCategory> list = categoryMapper.selectAll();
		List<CmsComment> list = commentMapper.selectAll();
		if(list!=null) {
			return list;
		}
		return new ArrayList<CmsComment>();
	}
	
	public boolean updateState(String commentId,String state) {
		int result = commentMapper.updateStateById(commentId, state);
		//返回结果代表更新的记录条数，如果一条都没有，代表数据不存在。
		if(result==0) { 
			return false;
		}
		return true;
	}	
	
}
